<?php $status = array('Schwebend'   => 'blue',
                      'Festgelegt'  => 'cyan',
                      'Geschlossen' => 'black',
                      'Gebucht'     => 'orange',
                      'Storniert'   => 'red',
                      'Fakturiert'  => 'green',
                     );
?>

<?php if(isset($trainings)):?>
<?php $this->load->helper('date'); ?>

<table class="table table-condensed table-striped">
    <tr><th>#</th><th>Fachthema</th><th>Teilnehmer</th><th>Termin</th><th>Ort</th><th>Status</th></tr>    
    <?php foreach($trainings as $training): ?>
    <tr><td><?php echo $training->id ;?></td>
        <td><?php echo anchor('/training/details/'.$training->id, $training->traininggroup()->course()->title) ;?></td>
        <td><?php echo $amount_participants[$training->id] ;?></td>
        <td><?php 
                  if (!is_null($training->appointment_to))
                      echo date("d.m.y H:i",strtotime($training->appointment_from)) .' bis '. date("d.m.y H:i",strtotime($training->appointment_to));
                  else
                      echo 'n/a';
            ?>
        </td>
        <td><?php 
                  if ($training->place_exists())
                    echo $training->place()->city;
                  else
                    echo 'n/a';
            ?>
        </td>
        <td><div rel="tooltip" title="<?php echo $training->trainingstatus()->description;?>" class="<?php echo $status[$training->trainingstatus()->name]; ?>" style="font-size: smaller; text-align: center; cursor: help"><?php echo $training->trainingstatus()->name ;?></div></td>
    </tr>
    <?php endforeach; ?>
</table>

<?php else:?>

<div class="alert alert-warning">Keine Massnahmen verfügbar</div>

<?php endif; ?>